import request from '@/utils/request'

/**
 * 获取当前用户书架
 * @returns 书籍列表
 */
export function getBookshelf() {
  return request({
    url: '/Book/GetBookshelf',
    method: 'post',
  })
}
/**
 * 获取书籍目录
 * @param {string} bookId 书籍编号
 * @returns 书籍目录
 */
export function getChapters(bookId) {
  return request({
    url: '/Book/GetChapters?bookId=' + bookId,
    method: 'post',
  })
}
/**
 * 获取内容
 * @param {*} chapterId 章节编号
 * @returns 章节内容
 */
export function getContents(chapterId) {
  return request({
    url: '/Book/GetContents?chapterId=' + chapterId,
    method: 'post',
  })
}

/**
 * 修改最后阅读章节
 * @param {*} param 修改参数
 * @returns
 */
export function modifyLastReadingChapter(param) {
  const { bookId, chapterId, lastReadingDateTime } = param
  return request({
    url: '/Book/ModifyLastReadingChapter',
    method: 'post',
    data: {
      bookId,
      chapterId,
      lastReadingDateTime,
    },
  })
}

/**
 * 获取书籍信息
 * @param {*} bookId 书籍编号
 * @returns 书籍信息
 */
export function getBookInfo(bookId) {
  return request({
    url: '/Book/GetBook',
    method: 'post',
    data: {
      bookId,
    },
  })
}

/**
 * 获取书籍下拉选项
 */
export function getBookSelectItems() {
  return request({
    url: '/Book/GetBookSelectItems',
    method: 'get',
  })
}
